package cn.edu.ntu.yyl.dao;

import cn.edu.ntu.yyl.pojo.article.Article;
import cn.edu.ntu.yyl.pojo.article.ArticleCategory;
import cn.edu.ntu.yyl.pojo.article.ArticleComment;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Mapper
@Repository
public interface ArticleDao {
    //根据ID查询
    Article SelectArticleById(Integer id);
    // 增
    Integer AddNewArticle(Article article);
    // 删
    Integer DeleteArticle(Article article);
    // 改
    Integer UpdateArticle(Article article);

    Integer UpdateKeyByID(String key,String value,Integer id);
    // 查
    List<Article> SelectArticle();
    //分页查询
    List<Article> SelectArticleSummary(Integer PageNo,Integer PageSize);
    //按照作者查询
    List<Article> SelectArticleByUserId(Integer id);
    //按照时间查询
    List<Article> SelectArticleByTime(Date before,Date after);
    //按照分类查询
    List<Article> SelectArticleByCategory(ArticleCategory articleCategory);
    //按照标签查询
    List<Article> SelectArticleByTag(ArticleCategory articleCategory);
    //更新文章的修改时间
    Integer UpdateArticleEditorTime(Article article);
    //标题模糊查询
    List<Article> SelectTitleByKeyword(String value);
    //内容模糊查询
    List<Article> SelectContentByKeyword(String value);
    //模糊查询
    List<Article> SelectArticleLike(String value);

    //时间线查询
    List<Article> SelectTodayArticle();
    List<Article> SelectYesterdayArticle();
    List<Article> SelectSevenDayArticle();
    List<Article> SelectFourteenDayArticle();
    List<Article> SelectMonthArticle();

    //获取置顶文章
    List<Article> SelectAllRecommendArticles();

    //增加点击次数
    int UpdateViews(Article article);

    //查询出文章评论数量并更新
    int UpdateCommentCountById(Article article);

    //查询出点赞次数并更新
    Integer UpdateGivelikeCount(Article article);
    //按照文章状态查询
    List<Article> SelectArticleByStatus(String status);
    //按照文章状态查询文章数量
    Integer SelectArticCountleByStatus(String status);
    //查询评论的文章
    Article SelectArticleByComment(ArticleComment articleComment);

}
